package cn.lingyangwl.agile.pay.pay.model.rqrs;

import cn.lingyangwl.agile.pay.model.rqrs.pay.ChannelRetMsg;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * 上游渠道侧响应信息包装类
 */
@Slf4j
@Getter
@Setter
@ToString
public class ChannelRetMsgExt extends ChannelRetMsg implements Serializable {

    public ChannelRetMsgExt() {
    }

    public ChannelRetMsgExt(ChannelState channelState, String channelOrderId, String channelErrCode, String channelErrMsg) {
        this.channelState = channelState;
        this.channelOrderId = channelOrderId;
        this.channelErrCode = channelErrCode;
        this.channelErrMsg = channelErrMsg;
    }

    /**
     * 明确成功
     */
    public static ChannelRetMsgExt confirmSuccess(String channelOrderId) {
        return new ChannelRetMsgExt(ChannelState.CONFIRM_SUCCESS, channelOrderId, null, null);
    }

    /**
     * 明确失败
     */
    public static ChannelRetMsgExt confirmFail(String channelErrCode, String channelErrMsg) {
        return new ChannelRetMsgExt(ChannelState.CONFIRM_FAIL, null, channelErrCode, channelErrMsg);
    }

    /**
     * 明确失败
     */
    public static ChannelRetMsgExt confirmFail(String channelOrderId, String channelErrCode, String channelErrMsg) {
        return new ChannelRetMsgExt(ChannelState.CONFIRM_FAIL, channelOrderId, channelErrCode, channelErrMsg);
    }

    /**
     * 明确失败
     */
    public static ChannelRetMsgExt confirmFail(String channelOrderId) {
        return new ChannelRetMsgExt(ChannelState.CONFIRM_FAIL, channelOrderId, null, null);
    }

    /**
     * 明确失败
     */
    public static ChannelRetMsgExt confirmFail() {
        return new ChannelRetMsgExt(ChannelState.CONFIRM_FAIL, null, null, null);
    }

    /**
     * 处理中
     */
    public static ChannelRetMsgExt waiting() {
        return new ChannelRetMsgExt(ChannelState.WAITING, null, null, null);
    }

    /**
     * 异常的情况
     */
    public static ChannelRetMsgExt sysError(String channelErrMsg) {
        return new ChannelRetMsgExt(ChannelState.SYS_ERROR, null, null, "系统：" + channelErrMsg);
    }

    /**
     * 状态未知的情况
     */
    public static ChannelRetMsgExt unknown() {
        return new ChannelRetMsgExt(ChannelState.UNKNOWN, null, null, null);
    }

    /**
     * 状态未知的情况
     */
    public static ChannelRetMsgExt unknown(String channelErrMsg) {
        return new ChannelRetMsgExt(ChannelState.UNKNOWN, null, null, channelErrMsg);
    }
}





